/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tamnhat.manager.model;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import telsoft.admin.util.AppServer;
import telsoft.sql.Database;

import com.tamnhat.entity.Service;

/**
 *
 * @author Administrator
 */
public class ServiceModel {
    public static ArrayList<Service> getAll() throws Exception{
        ArrayList<Service> list = new ArrayList<Service>();
        Connection cn = null;
        Statement st = null;
        ResultSet rs = null;
        String strSQL = " select service_id,service_name from sdp_services ";
        try {
            cn = AppServer.getConnection();
            st = cn.createStatement();
            rs = st.executeQuery(strSQL);
            while (rs.next()) {
               Service s = new Service();
               s.setId(rs.getString(1));
               s.setName(rs.getString(2));
               list.add(s);
            }
        } finally {
            Database.closeObject(rs);
            Database.closeObject(st);
            Database.closeObject(cn);
        }
        return list;
    }
}
